package com.xl.flinkdemo.source;

import com.xl.flinkdemo.beans.SensorReding;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

/**
 * @ClassName SourceTest_Collecttion2
 * @Description TODO
 * @Author hxl
 * @Date 2021/4/14 15:08
 * Version 1.0
 **/
public class SourceTest_Collecttion2 {

  public static void main(String[] args) throws Exception {
    //创建执行环境
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    //按顺序输出
    env.setParallelism(1);
    //从文件中读取数据
    DataStreamSource<String> stringDataStreamSource =
        env.readTextFile("D:\\studyspace\\flinkdemo\\src\\main\\resources\\sensor.txt");

    //打印输出
    stringDataStreamSource.print();

    //执行
    env.execute("jobName_TestSourceJob");
  }

}
